package com.jadefashion.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.jadefashion.health.entity.QueryPageBean;
import com.jadefashion.mapper.CheckitemMapper;
import com.jadefashion.pojo.CheckItem;
import com.jadefashion.service.CheckitemService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class CheckitemServiceImpl implements CheckitemService {
    @Autowired
    private CheckitemMapper checkitemMapper;
    //这行代码只要我才能看得懂
    @Override
    public List<CheckItem> findAll() {
        List<CheckItem> list=checkitemMapper.findAll();
        return list;
    }

    @Override
    public void updateCheckitemByCondition(CheckItem checkItem) {
        checkitemMapper.updateCheckitemByCondition(checkItem);
    }

    @Override
    public void deleteCheckitemById(Integer id) {
        checkitemMapper.updateCheckitemStatusById(id);
    }

    @Override
    public void addCheckitem(CheckItem checkItem) {
        checkitemMapper.addCheckitem(checkItem);
    }

    @Override
    public Map<String, Object> findPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        List<CheckItem> list= checkitemMapper.findPage(queryPageBean.getQueryString());
        PageInfo<CheckItem> checkItemPageInfo = new PageInfo<>(list);
        HashMap<String, Object> map = new HashMap<>();
        map.put("total",checkItemPageInfo.getTotal());
        map.put("list",checkItemPageInfo.getList());
        return map;
    }
}
